//
//  ViewController.swift
//  useCamera
//
//  Created by liy on 2025/1/18.
//

import UIKit

class ViewController: UIViewController, UIImagePickerControllerDelegate & UINavigationControllerDelegate {

	@IBOutlet weak var imageView: UIImageView!
	override func viewDidLoad() {
		super.viewDidLoad()
		// Do any additional setup after loading the view.
	}


	@IBAction func openCamera(_ sender: Any) {
		let vc = UIImagePickerController()
		vc.modalPresentationStyle = .overFullScreen
		vc.delegate = self
		vc.sourceType = .photoLibrary
		present(vc, animated: true)
	}
	func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
		if let img =  info[.originalImage] as? UIImage {
			print(img)
			self.imageView.image = img
			picker.dismiss(animated: true)
		}
	}
}

